package com.atguigu.iterator;

import java.util.Iterator;


/**
 * @Description: 具体的迭代器
 * @Author lixiaolong
 * @Date 2023/10/11
 */
public class ComputerCollegeIterator implements Iterator {

    //数组方式存储 Department
    Department[] departments;
    int position = 0; //遍历的位置


    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    //判断是否还有下一个元素
    @Override
    public boolean hasNext() {
        return position < departments.length && departments[position] != null;
    }

    // 取出下一个元素
    @Override
    public Object next() {
        Department department = departments[position];
        position++;
        return department;
    }

    //删除方法  默认空
    public void remove() {

    }

}
